package com.handinglian.ai.common.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class StaticResourceConfig extends WebMvcConfigurerAdapter {
    @Value("${static.resources.location}")
    private String staticResourcesLocation;
    @Value("${static.resources.url}")
    private String staticResourcesUrl;

    @Value("${file.download.url}")
    private String fileDownloadUrl;
    @Value("${file.download.location}")
    private String fileDownloadLocation;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(staticResourcesUrl+"**").addResourceLocations("file:"+staticResourcesLocation);
        registry.addResourceHandler(fileDownloadUrl+"**").addResourceLocations("file:"+fileDownloadLocation);
        super.addResourceHandlers(registry);
    }
}
